﻿@model UserInterop
@{ 
    ViewBag.Title = "For Trainers";
    var upcoming = Model.UpcomingModulesTaught().ToList();
    var past = Model.PastModulesTaught().ToList();
}

<div class="fortrainers">
    <fieldset>
        <legend>Upcoming Modules</legend>
        <p class="padtop">Below are the modules that you are currently speaking at.</p>
        @if (upcoming.Count > 0)
        {
            <table class="wide">
                <thead>
                    <tr>
                        <th>Title</th>
                        <th>Description</th>
                        <th>Date</th>
                        <th>Location</th>
                        <th style="width: 130px">Registered Users</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (Module m in upcoming)
                    {
                        ContextManager.CurrentDb.Entry(m).Reference(md => md.Venue).Load();
                        var regCount = m.Owners.Count();
                        <tr>
                            <td>@m.LinkToItem(Html, m.Title)</td>
                            <td class="markup">@Html.Raw(m.Teaser)</td>
                            <td>@Html.Raw(m.WhenHtml())</td>
                            <td>@Html.Raw(m.Venue.ToAddressHtml())</td>
                            <td>@regCount / @m.MaxEnrollment  @Html.ActionLink("View Details", "ModuleDetails", new { id = m.Id })</td>
                        </tr>
                    }
                </tbody>
            </table>
        }
        else
        {
            <p>You are not currently hosting any modules.</p>
        }
    </fieldset>
    @if (past.Count > 0)
    {
        <fieldset>
            <legend>Past Modules</legend>
            <p class="padtop">View feedback for past modules that you spoke at.</p>
            <table>
                <thead>
                    <tr>
                        <th>Title</th>
                        <th>Description</th>
                        <th>Date</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var m in past)
                    {
                        <tr>
                            <td>@m.Title</td>
                            <td class="markup">@Html.Raw(m.Teaser)</td>
                            <td>@m.Start.ToShortDateString()</td>
                            <td>@Html.ActionLink("View Feedback", "ModuleDetails", new { id = m.Id })</td>
                        </tr>
                    }
                </tbody>
            </table>
       </fieldset>
    }
</div>
